﻿@using WineStore.Extends;
@using PagedList.Mvc;
@using PagedList;
@model PagedList.IPagedList<WineStore.Models.News>
@{
    ViewBag.Title = "ShowNews";
    Layout = "~/Views/Shared/AdminLayout.cshtml";
}
@section Styles
{
    <!--Sử dụng cho autocomplete-->
    <link href="../../Content/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />
    <!--Sử dụng cho paging-->
    <link href="../../Content/PagedList.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        input, textarea, select {
            padding: 5px;
            border: 1px solid #ccc;
            border-radius: 3px;
            width: 200px;
            color: #333;
            box-shadow: rgba(0,0,0,0.1)0px 0px 8px;
            -moz-box-shadow: rgba(0,0,0,0.1)0px 0px 8px;
            -webkit-box-shadow: rgba(0,0,0,0.1)0px 0px 8px;
        }

        textarea {
            width: 400px;
            height: 100px;
            max-width: 400px;
            line-height: 18px;
            border-radius: 3px;
        }


            input:hover, textarea:hover, select:hover input:focus, textarea:focus, select:focus {
                border-color: 10px solid #C9C9C9;
                box-shadow: rgba(0,0,0,0.2)0px 0px 8px;
                -moz-box-shadow: rgba(0,0,0,0.2)0px 0px 8px;
                -webkit-box-shadow: rgba(0,0,0,0.2)0px 0px 8px;
                border-radius: 3px;
            }

        input .submit {
            height: 38px;
            background-color: #474E69;
            color: #FFF;
            border-radius: 3px;
            -moz-border-radius: 3px;
            -webkit-border-radius: 3px;
        }

        td {
            text-align: center;
            vertical-align: middle;
        }
    </style>
}

@section Scripts
{
    <!--Sử dụng cho autocomplete-->
    <script src="../../Scripts/jquery-ui-1.8.11.min.js" type="text/javascript"></script>
    <!--Sử dụng cho row hover-->
    <script type="text/javascript">
        $(document).ready(function () {
            $("tr").not(':first').hover(function () {
                $(this).css("background", "#F0FFFF");
            }, function () {
                $(this).css("background", "");
            }
            );
        });
    </script>
    <!--Sử dụng cho autocomplete-->
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            $('*[data-autocomplete-url]')
        .each(function () {
            $(this).autocomplete({
                source: $(this).data("autocomplete-url")
            });
        });
        });
    </script>
}
<link href="../../Content/styletablesim.css" rel="stylesheet" />

<script type="text/javascript">
    $(function () {
        /* For zebra striping */
        $("table tr:nth-child(odd)").addClass("odd-row");
        /* For cell text alignment */
        $("table td:first-child, table th:first-child").addClass("first");
        /* For removing the last border */
        $("table td:last-child, table th:last-child").addClass("last");
    });
</script>
<!-- Table (TABLE) -->
@if (Session["Admin"] != null)
{
    <h3 class="tit">Danh Sách Tin Tức
    </h3>
    <div style="color: Red; font-size: 13px;" id="update-message">
    </div>
    <div style="float: right; padding: 0px;">
        @using (Html.BeginForm())
        {
            @Html.DropDownList("NewsAmount", null, new { style = "width:200px;" })
        }
    </div>
        using (Html.BeginForm())
        {
    <p style="font-size: 15px;">
        Danh mục tin tức @Html.TextBox("SearchString", ViewBag.CurrentFilter as string, new { data_autocomplete_url = Url.Action("Autocomplete") })
        <input type="submit" value="Tìm kiếm" style="width: 70px; cursor: pointer;" />
    </p>
    <table style="width: 100%; border:1px">
        <tr>
            <th>Ngày đưa tin
            </th>
            <th>Danh mục tin tức
            </th>
            <th>Tiêu đề
            </th>
            @*<th>Mô tả
            </th>*@
            <th>Ảnh
            </th>
            <th>Sự kiện
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(news => item.DateAdd)
                </td>
                <td>
                    @Html.DisplayFor(news => item.CategoryNews.CategoryNewsName_VN)
                </td>
                <td>
                    @Html.DisplayFor(news => item.NewsTitle_VN)
                </td>
                @*<td>
                    @Html.DisplayFor(news => item.NewsDescription_VN)
                </td>*@
                <td>
                    @Html.ImageFor(news => "../../Content/Images/News/" + item.NewsImage, new { width = "120px", height = "100px", alt = "some alt text" })
                </td>
                <td>
                    @Html.ActionLink("Sửa", "EditNews", new { id = item.NewsId }, new { @class = "edit" })
                    @Html.ActionLink("Xóa", "DeleteNews", new { id = item.NewsId }, new { @class = "edit" })
                </td>
            </tr>
        
        }
        <tr>
            <td colspan="9" align="right" style="text-align: right; vertical-align: bottom;">
                @Html.ActionLink("Thêm mới", "CreateNews", null, new { @class = "edit" })
            </td>
        </tr>
    </table>
    <!--Paging-->
    @Html.PagedListPager(Model, page => Url.Action("ShowNews", new { page = page, currentFilter = ViewBag.CurrentFilter, currentNewsAmount = ViewBag.CurrentNewsAmount }), (PagedListRenderOptions)ViewBag.Pro)
        }

}
else
{
    Response.Redirect("~/Admin/LogOn/");
}
<script type="text/javascript">
    $(function () {
        $('#NewsAmount').change(function () {
            this.form.submit();
        });
    });
</script>
